Don't let the high-falutin' name fool you. A URL is basically just a file name. It tells the browser the server, directory, file name, and extension, so that the browser knows how to retrieve the file.
protocol://domain/directory/name.ext#anchor
Here's what all the pieces mean:
protocol |
The communication protocol that should be used to retrieve the data.
There are many possible protocols, but here are the ones you are most
likely to see (and use):
|
||||||||
domain | The domain name for the server where the resource (file) lives. This is something like whitehouse.gov or www.winmag.com. There's no requirement that a domain name for a Web site start with "www" but it's a common convention. | ||||||||
directory | Directory on the web server where the resource is located. If the resource is in the "home" directory there won't be a directory name. | ||||||||
name.ext | The name of the resource (a file, usually). The name doesn't need to be limited to the 8.3 DOS file names. The actual name limits depend on the files on the Web server, not on the browser requesting the file. | ||||||||
anchor | A location in the HTML file that should be displayed. In a large document, this lets you jump to a point other than the top of the file. |
If you don't specify a file name the Web server usually chooses a default file name such as default.htm or index.html. The actual default name of the file is determined by the server, not the browser.
http://www.yahoo.com/ | Loads the default page from the Yahoo server. The trailing slash could have been left off. |
../common/sitemap.htm | This is a "relative URL" that loads the page http://www.winmag.com/common/sitemap.htm. The ".." in the URL says to go up one level in the directory structure; that takes you from "/news" to "/". |
/common/sitemap.htm | Another relative URL that loads the page http://www.winmag.com/common/sitemap.htm. Since the protocol and domain weren't specified, the ones for the current page are used. |
oldnews.htm | Still yet another relative URL that loads http://www.winmag.com/news/oldnews.htm. |
#RegistryInfo | Moves to the anchor point named "RegistryInfo" in the current page. If there isn't such an anchor, most browsers will just jump to the top of the page. |
If you use absolute URLs to pages that you're in the process of building on your local hard disk, you won't be able to test those links locally. Still, there are pluses to absolute URLs. If someone copies a file off your web server onto their hard disk and later views it, the absolute URL references will still go to the right location. Relative references will break unless the person copied the referred-to files to their local disk as well.
I generally favor relative references to the greatest extent possible, unless you know the file will often be copied and used for local browsing. Even then, you may find it's best to create a specially-edited package of files that people can download. That way they'll see exactly what you intended, graphics and all.